package com.base.pig.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.base.pig.entity.SensorParams;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author yjh
 * @since 2022-11-18
 */
@Mapper
public interface SensorParamsMapper extends BaseMapper<SensorParams> {


    @Select("select  DATE_FORMAT( p.update_time , '%H') as  hour,p.attribute_data  as data from  sensor_params p" +
            "    WHERE DATE_FORMAT( p.update_time , '%Y-%m-%d')= #{date} and  p.attribute_code=#{attributeCode}  and  sn_code=#{sncode}  " +
            "    group by    DATE_FORMAT( p.update_time , '%Y-%m-%d %H') ")
    List<Map<String, Object>> getSensorParams(@Param("sncode") String sncode, @Param("attributeCode") String attributeCode, @Param("date") String date);
}
